home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
MATHS
/
RLAB
/
RLAB125.ZIP
/
!RLaB
/
examples
/
euclid
< prev
next >
Wrap
Text File
|
1994-09-20
|
468b
|
27 lines
//-------------------------------------------------------------------//
// Euclid's algorithm
//
// Syntax: euclid ( M , N )
// Description:
// Euclid's algorithm computes the greatest common divisor of two
// integers (M, and N).
//-------------------------------------------------------------------//
euclid = function ( M , N )
{
local( M, N )
r = 1;
while(r)
{
r = mod(M,N);
if(r == 0) { break; }
M = N;
N = r;
}
return N;
};